import { View } from "../../../mvc/core/View";
import { Language } from "../../../../extend/language/Language";
import { LayerManager } from "../../manager/LayerManager";
import { ObjCreate } from "../common/ObjCreate";
import { MuiEvent } from "../../../../com/mui/events/MuiEvent";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { GTextBar } from "../range/GTextBar";
import { GBoxDirection } from "../../../../com/mui/containers/globalVariable/GBoxDirection";
import { GameDefConfig } from "../../resource/GameDefConfig";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { ClockManager } from "../../manager/ClockManager";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
import { DefInfo } from "../../resource/info/DefInfo";
type int = number;
//class EveryDayActivePanel
    
    export  class EveryDayActivePanel extends View
    {
        constructor()
        {
            this._dayBarDp = [{"color": 16750899, "text": Language.getString(20982)}, {"color": 16750899, "text": Language.getString(20983)}, {"color": 16750899, "text": Language.getString(20984)}, {"color": 16750899, "text": Language.getString(20985)}, {"color": 16750899, "text": Language.getString(20986)}, {"color": 16750899, "text": Language.getString(20987)}, {"color": 16750899, "text": Language.getString(20988)}];
            super();
            layer = LayerManager.windowLayer;
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(0, -10, 330, 434, this);
            this._dayBar = this.createTextBar(20, 10, this._dayBarDp);
            this._dayBar.addEventListener(MuiEvent.GTABBAR_SELECTED_CHANGE, this.onDayBarSelectChangeHandler);
            this._descTxt = ObjCreate.createGTextField("", 20, 35, 300, 350, this, GlobalStyle.textFormat1);
            this._descTxt.multiline = true;
            this._descTxt.wordWrap = true;
            this._descTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            return;
        }

        /* internal  */createTextBar(arg1: int, arg2: int, arg3: Array<any>): GTextBar
        {
            var loc1;
            (loc1 = new GTextBar()).textWidth = 40;
            loc1.verticalGap = 3;
            loc1.x = arg1;
            loc1.y = arg2;
            loc1.direction = GBoxDirection.HORIZONTAL;
            loc1.dataProvider = arg3;
            loc1.selectedIndex = 0;
            loc1.selectedColor = 52275;
            addChild(loc1);
            return loc1;
        }

        /* internal  */onDayBarSelectChangeHandler(arg1: MuiEvent=null): void
        {
            var loc1=this._dayBar.selectedIndex;
            var loc2=loc1 + 1;
            this.updateDay(loc2);
            return;
        }

        /* internal  */updateDay(arg1: int): void
        {
            this._defInfo = GameDefConfig.instance.getEveryDayActiveInfo(arg1);
            if (this._defInfo) 
            {
                this._descTxt.htmlText = "<textFormat leading=\'4\'>" + HTMLUtil.getHtmlByComp(this._defInfo.text1) + "</textFormat>";
            }
            return;
        }

        public updateTodayActive(): void
        {
            var loc1=ClockManager.instance.nowDate;
            var loc2=loc1.day;
            var loc3=-1;
            if (loc2 == 0) 
            {
                loc3 = 6;
            }
            else 
            {
                --loc3;
            }
            this._dayBar.selectedIndex = loc3;
            this.onDayBarSelectChangeHandler();
            return;
        }

        /* internal */ /* var */_dayBar: GTextBar;

        /* internal */ /* var */_descTxt: GTextFiled;

        /* internal */ /* var */_dayBarDp: Array<any>;

        /* internal */ /* var */_defInfo: DefInfo;
    }
